package cn.softcits.network.two;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketServer {
    public static void main(String[] args) throws IOException {
        ServerSocket server = new ServerSocket(11000);
        Socket client = server.accept();
        PrintWriter out = new PrintWriter(client.getOutputStream(), true);
        BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
        String line = null;
        while ((line = in.readLine()) != null)
            System.out.println(line);

        out.write("HTTP/1.1 200 OK\n");
        out.write("Server:apache-Coyote/1.1\n");
        out.write("Content-Type:text/html;charset=utf-8\n");
        out.write("Happy birthday, my browser.");
        server.close();
    }
}